<template>
	<view class="pbgf">
		<view class="content pr">
			<view class="flex_y">
				<image class="logo_img" src="/static/login/logo.png" mode=""></image>
			</view>
			<view class="mt24 tc c2a7 fw500 fs44">欢迎登录清洁熊</view>
			<view class="mt100 flex_y">
				<zh-button openType="getPhoneNumber" @getphone='getphone'>
					<view class="btn flex_c cf fw500 fs26 flex_c">一键登录</view>
				</zh-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {

			}
		},
		onLoad() {

		},
		onShow() {

		},
		methods: {
			getphone(e) { //获取手机号登录
				uni.login({
					success: (loginRes) => {
						this.$api.login({
							code: loginRes.code,
							phoneCode: e
						}).then(res => {
							console.log(res);
							if (res.code == 1) {
								this.$store.commit('saveUserInfo', res.data)
								this.$store.commit('saveToken', res.data.token)
								this.$store.commit('saveIdentity', res.data.group_id)
								this.$toast.toast(res.msg)
								setTimeout(() => {
									if (getCurrentPages().length > 1) {
										uni.navigateBack();
									} else {
										// 需要判断是什么角色
										uni.switchTab({
											url: '/pages/share//my/my'
										});
									}
								}, 1500)
							} else {
								this.$toast.toast(res.msg)
							}
						})
					}
				});
			},
		},
		computed: {

		},
		watch: {

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		top: 142upx;

		.logo_img {
			width: 222upx;
			height: 219upx;
		}

		.btn {
			width: 557upx;
			height: 74upx;
			background: #2A71C0;
			border-radius: 40upx;
		}
	}
</style>
